home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
FSEEK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1984-07-31
|
682b
|
34 lines
/* fseek.c - reposition a stream.
(C) Copyright 1984 Gregory R. Mansfield - All Rights Reserved.
G. R. Mansfield. 84/07/26.
Ver 1.0-4731.
*/
#include <stdio.h>
int fseek(fp, offset, org) /* reposition a stream */
FILE *fp;
long offset;
int org;
{
long np;
if (fp->_flag & _WRITE) {
fflush(fp);
fp->_cnt = 0;
}
if (org == 1) {
np = offset + (long)(fp->_ptr - fp->_base);
if (np > 0L && np < (long)fp->_cnt) { /* in buffer */
fp->_ptr = fp->_base + np;
fp->_cnt = BUFSIZE - np;
return(0);
}
offset = offset - (long)fp->_cnt;
}
fp->_cnt = 0;
fp->_ptr = fp->_base;
lseek(fp->_fd, offset, org);
fp->_flag &= ~_EOF;
}